// vue.config.js
const { defineConfig } = require('@vue/cli-service')
const path = require('path')
const MonacoWebpackPlugin = require('monaco-editor-webpack-plugin')

module.exports = defineConfig({
  transpileDependencies: true,
  
  configureWebpack: {
    resolve: {
      alias: {
        '@': path.resolve(__dirname, 'src')
      }
    },
    plugins: [
      new MonacoWebpackPlugin({
        languages: ['c', 'cpp', 'java', 'python', 'javascript', 'typescript']
      })
    ],
    optimization: {
      splitChunks: {
        cacheGroups: {
          monaco: {
            test: /[\\/]node_modules[\\/]monaco-editor[\\/]/,
            name: 'monaco',
            chunks: 'all',
            priority: 10
          }
        }
      }
    }
  },

  chainWebpack: (config) => {
    // 定义全局变量
    config.plugin('define').tap((args) => {
      args[0]['__VUE_PROD_HYDRATION_MISMATCH_DETAILS__'] = true
      return args
    })
  },

  devServer: {
    port: 8080,
    open: true,
    client: {
      overlay: false
    }
  }
})